from robot.comm.priority import Priority
from robot.comm.pluginBase import PluginBase
from alicebot.adapter.mirai.event import FriendInputStatusChangedEvent, MessageEvent


class FilterPlugin(PluginBase, priority=Priority.Filter):
    async def handle(self) -> None:
        pass

    async def rule(self) -> bool:
        # 过滤好友输入状态改变事件
        if isinstance(self.event, FriendInputStatusChangedEvent):
            return True
        # 过滤聊天分享消息
        if isinstance(self.event, MessageEvent):
            for seg in self.event.message:
                if seg.type == 'Forward':
                    return True
        return False
